﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace RL
{
    /// <summary>
    /// Логика взаимодействия для ucVehicleType.xaml
    /// </summary>
    public partial class ucVehicleType : UserControl
    {


        public routelistEntities ContextDB
        {
            get { return (routelistEntities)GetValue(ContextDBProperty); }
            set { SetValue(ContextDBProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ContextDB.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ContextDBProperty =
            DependencyProperty.Register("ContextDB", typeof(routelistEntities), typeof(ucVehicleType), new UIPropertyMetadata(null));

        

        public vehicle_type VehicleType
        {
            get { return (vehicle_type)GetValue(VehicleTypeProperty); }
            set { SetValue(VehicleTypeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for VehicleType.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty VehicleTypeProperty =
            DependencyProperty.Register("VehicleType", typeof(vehicle_type), typeof(ucVehicleType), new UIPropertyMetadata(null, new PropertyChangedCallback(propCallBack)));

        private static void propCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ucVehicleType uc = d as ucVehicleType;
            if (null == uc) return;
            uc.textBlock1.Text = "<не указан>";
            if (null != e.NewValue)
            {
                vehicle_type it = e.NewValue as vehicle_type;
                if (null != it)
                {
                    uc.textBlock1.Text = it.name.Trim();
                }
            }
        }
        public ucVehicleType()
        {
            InitializeComponent();
        }

        private void buttonSelect_Click(object sender, RoutedEventArgs e)
        {
            if (null == ContextDB) return;

        }
    }
}
